package com.sky.controller.admin;


import com.sky.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.models.auth.In;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

@RestController("adminShopController")
@Slf4j
@RequestMapping("/admin/shop")
@Api(tags = "店铺相关接口")
public class ShopController {

    public static final String Key = "SHOP_STATUS" ;
//    @Autowired
//    ShopService shopService = new ShopService();

    @Autowired
    private RedisTemplate redisTemplate;



    @PutMapping("/{status}")
    @ApiOperation("改变店铺营业状态")
    public Result setStatus(@PathVariable Integer status){

        log.info("设置店铺状态为：{}",status);
//        shopService.setStatus(status);
        redisTemplate.opsForValue().set(Key,status);
        return Result.success();

    }

    @GetMapping("/status")
    @ApiOperation("获取店铺营业状态")
    public Result<Integer> getStatus(){


        Integer shopStatus = (Integer)redisTemplate.opsForValue().get(Key);


        return Result.success(shopStatus);
    }


}
